/**
 * 
 */
package com.oet.webservice.basic;

import java.util.List;
import java.util.ArrayList;

import javax.jws.WebService;


import com.oet.service.manager.FileManager;
/**
 * @author y140zhan
 *
 */
//@WebService(endpointInterface = "com.ydk.webservice.contactus.ContactUsService")
public final class ContactUsServiceImpl implements ContactUsService {

    public List<Message> getMessages() {
        List<Message> messages = new ArrayList<Message>();
        messages.add(new Message(
                "Willie", "Wheeler", "中国@xyz.com", "Great job"));
        messages.add(new Message(
                "Dardy", "Chen", "dardy.chen@xyz.com", "I want my money back"));
        return messages;
    }

    public void postMessage(Message message) {
        System.out.println(message);
    }

	public byte[] getFile() {
		// TODO Auto-generated method stub

		//Check the fileName is valid;

//		UploadedFile image = FileManager.loadUploadedFile(FileManager.getPath(FileManager.FILE_KEY_BOOK) + "test.txt");
//		return image.getFileContent();
		return null;

	}

	public void postFile(String fileName, byte[] content) {
		// TODO Auto-generated method stub
		String realName = FileManager.getPath(FileManager.FILE_KEY_COURSE) + fileName;
		FileManager.saveAsFile(realName, content);
		
	}

	public byte[] getFileByName(String name) {
		String realName = null;
		if (name != null && !name.isEmpty())
		{
			//Check the fileName is valid;
			realName = FileManager.getPath(FileManager.FILE_KEY_COURSE) + name;
			String checkResult = FileManager.checkFileName(realName);
			if (checkResult != null)
			{
				return null;
			}

		}
		return null;
	}
}
